package com.webflux.util;

import com.webflux.exceptions.CheckException;

import java.util.stream.Stream;

/**
 * Created by wangzhanjin on 2018/5/31.
 */
public class CheckUtil {
    private static final String[] INVALID_NAMES = {"admin", "guanliyuan"};
    /**
     * 校验名字，不成功抛出校验异常
     * @param value
     */
    public static void checkName(String value) {
        Stream.of(INVALID_NAMES).filter(name->name.equalsIgnoreCase(value))
                //断言
        .findAny().ifPresent(name->{
            throw new CheckException("name", value);
        });
    }
}
